package com.barbeque.mall.exception;

import com.barbeque.mall.bean.BaseRespVoNoData;
import com.fasterxml.jackson.databind.exc.InvalidFormatException;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author Euphonium
 * @since 2022/07/21
 */
@RestControllerAdvice
public class CustomExceptionControllerAdvice {
    @ExceptionHandler(InvalidFormatException.class)
    public BaseRespVoNoData invalidFormatException(InvalidFormatException e) {
        e.printStackTrace();
        return BaseRespVoNoData.error(402, "参数值不对");
    }

    @ExceptionHandler(DataIntegrityViolationException.class)
    public BaseRespVoNoData dataIntegrityViolationException(DataIntegrityViolationException e) {
        e.printStackTrace();
        return BaseRespVoNoData.error(502, "系统内部错误");
    }

}
